package com.atguigu.usercenterservice.utils;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Component;

/**
 * 当项目已启动，spring接口，spring加载之后，执行接口一个方法
 */
@Component
@RefreshScope   //动态刷新配置文件中的内容   @Value获取配置中心内容
public class WechatPropertiesUtils implements InitializingBean {

    //读取微信开发者平台配置文件内容
    @Value("${wx.open.app_id}")
    private String appId;

    @Value("${wx.open.app_secret}")
    private String appSecret;

    @Value("${wx.open.redirect_url}")
    private String redirectUrl;


    //定义公开静态常量
    public static String APP_ID;
    public static String APP_SECRET;
    public static String REDIRECT_URL;


    @Override
    public void afterPropertiesSet() throws Exception {
        APP_ID = appId;
        APP_SECRET = appSecret;
        REDIRECT_URL = redirectUrl;
    }
}
